package club.zhaoliang.study.xcrash;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.view.View;
import android.widget.TextView;

import club.zhaoliang.study.R;
import xcrash.XCrash;

public class XcrashActivity extends AppCompatActivity {


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_xcrash);
        //java crash
        findViewById(R.id.tvTestJavaCrash).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                XCrash.testJavaCrash(true);

            }
        });
        //native crash
        findViewById(R.id.tvTestNativeCrash).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                XCrash.testNativeCrash(false);

            }
        });
        //anr
        findViewById(R.id.tvTestANR).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                while (true) {
                    try {
                        Thread.sleep(1 * 60 * 1000);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }

                }
            }
        });

    }
}
